<script lang="ts" setup>
import { reactive, toRefs } from 'vue'
import Api from '@/api/'
import to from '@/utils/awaitTo'
import { message } from 'ant-design-vue'

// 引用声明
const props = defineProps({
  row: {
    type: Object,
    default: () => {
    }
  }
})

// 响应式数据
const state = reactive({
  loading: false
})

// 响应式数据解析
const { loading } = toRefs(state)


const emits = defineEmits(['callback'])


// 点击事件
const handleTrunText = async () => {
  const params = {
    type: 2,
    videoId: props.row.videoId
  }
  loading.value = true;
  const [error, data] = await to(Api.video.videoFileTrans(params))
  loading.value = false;

  if (!error) {
    message.success("转化成功");
    emits('callback', data)
  }
}
</script>

<template>
  <div>
    <a-button :loading="loading" type="primary" @click="handleTrunText">{{ loading ? '转文字中...'
      : '转文字' }}
    </a-button>
  </div>
</template>

<style lang="less" scoped>

</style>
